import React, { Component } from 'react'
import Son from "./son.jsx"
import axios from "axios"
import Dau from "./dau"
import Son1 from "./son1.jsx"
import context from "../utils/context"
import Fun from "./fun.jsx"
let {Provider} = context
class Home extends Component {
  state = {
    flag:true,
    arr:[],
    num:false

  }
  componentDidMount(){
     axios.get("/list").then(res=>{
        //  console.log(res.data)
         this.setState({
            arr:res.data.list
        })
     })
  }
  render() {
    return (
      <Provider value={"我是爷爷的数据"}>
            <div>
          <button onClick={()=>{this.setState({flag:!this.state.flag})}}>点击我创建和删除子组件</button>
          {/* {
              this.state.arr&&this.state.arr.length?  <Son send={this.state.arr}></Son>:""
          } */}
          <Son send={"我是爷爷传递过来的参数"}></Son>
          <Dau/>
          <Son1></Son1>
          <Fun></Fun>
          
      </div>

      </Provider>
    
    )
  }
}

export default Home